package org.davidliebman.android.awesomecube;


import android.util.Log;
import android.content.*;

public class SimpleEdge extends Mesh {
	
//	int mFace1;
//	int mFace2;
	
	public SimpleEdge(Context c) {
		super(c);
		mContext = c;
		this.settupArrays();

		this.preBuildMesh();
	} 
	
	public SimpleEdge(Context c, int face1, int face2) {
		super(c);
		mContext = c;
		mFace1 = face1;
		mFace2 = face2;
		this.settupArrays();

		this.preBuildMesh();
	}
	
	public SimpleEdge(Context c, Positioning mP, int face1, int face2, int face3) {
		super(c);
		mContext = c;
		mFace1 = face1;
		mFace2 = face2;
		mFace3 = face3;
		mP1 = mP;// mP1
		this.settupArrays();

		this.preBuildMesh();
		//this.addToMP0(mP);

	}
	
//	public void setFaces(int m1, int m2) {
//		if (m1 != TextureLibrary.NONE) mFace1 = m1;
//		if (m2 != TextureLibrary.NONE) mFace2 = m2;
//	}
	
	@Override
	public void settupArrays() {
	
		if ( ! this.mShouldLoadArrays) return;
		
		
		this.mShouldLoadTexture = true;
		
		if(mP1.ix == Mesh.XPOS && mP1.iy == Mesh.YNEG && mP1.iz == Mesh.MIDD) {
			this.addMeshPart(new MeshPartPlaneX(mFace1 , true, 2, 1, 0)); //
			this.addMeshPart(new MeshPartPlaneY(mFace2, false, 1,2,0)); //
			this.addMeshPart(null); //
		}
		else if(mP1.ix == Mesh.MIDD && mP1.iy == Mesh.YNEG && mP1.iz == Mesh.ZNEG) {
			this.addMeshPart(null); //
			this.addMeshPart(new MeshPartPlaneY(mFace2, false, 0, 2,1)); //
			this.addMeshPart(new MeshPartPlaneZ(mFace3, false, 0 ,1, 2)); //
		}
		else if(mP1.ix == Mesh.XNEG && mP1.iy == Mesh.YNEG && mP1.iz == Mesh.MIDD) {
			this.addMeshPart(new MeshPartPlaneX(mFace1 , false, -1, 1, 0)); // 
			this.addMeshPart(new MeshPartPlaneY(mFace2, false, -1, 2, 0 )); // 
			this.addMeshPart(null); //
		}
		else if(mP1.ix == Mesh.XNEG && mP1.iy == Mesh.MIDD && mP1.iz == Mesh.ZNEG) {
			this.addMeshPart(new MeshPartPlaneX(mFace1 , false, -1, 0, 1)); // 
			this.addMeshPart(null); //
			this.addMeshPart(new MeshPartPlaneZ(mFace3, false, -1 ,0, 2)); // 
		}
		else if(mP1.ix == Mesh.MIDD && mP1.iy == Mesh.YPOS && mP1.iz == Mesh.ZNEG) {
			this.addMeshPart(null); //
			this.addMeshPart(new MeshPartPlaneY(mFace2, true, 0, -1, 1 )); //
			this.addMeshPart(new MeshPartPlaneZ(mFace3, false, 0 ,-1, 2)); // 
		}
		else if(mP1.ix == Mesh.XPOS && mP1.iy == Mesh.MIDD && mP1.iz == Mesh.ZNEG ) {
			this.addMeshPart(new MeshPartPlaneX(mFace1 , true, 2, 0, 1)); // 
			this.addMeshPart(null); //
			this.addMeshPart(new MeshPartPlaneZ(mFace3, false, 1 , 0, 2)); // 
		}
		else if(mP1.ix == Mesh.XPOS && mP1.iy == Mesh.YPOS && mP1.iz == Mesh.MIDD ) {
			this.addMeshPart(new MeshPartPlaneX(mFace1 , true, 2, -1, 0)); // 
			this.addMeshPart(new MeshPartPlaneY(mFace2, true, 1, -1, 0 )); // 
			this.addMeshPart(null); //
		}
		else if(mP1.ix == Mesh.XPOS && mP1.iy == Mesh.MIDD && mP1.iz == Mesh.ZPOS ) {
			this.addMeshPart(new MeshPartPlaneX(mFace1 , true, 2, 0, -1)); // 
			this.addMeshPart(null); //
			this.addMeshPart(new MeshPartPlaneZ(mFace3, true, 1 , 0, -1)); // 
		}
		else if(mP1.ix == Mesh.MIDD && mP1.iy == Mesh.YPOS && mP1.iz == Mesh.ZPOS ) {
			this.addMeshPart(null); //
			this.addMeshPart(new MeshPartPlaneY(mFace2, true, 0, -1, -1 )); // 
			this.addMeshPart(new MeshPartPlaneZ(mFace3, true, 0 , -1, -1)); // 
		}
		else if(mP1.ix == Mesh.XNEG && mP1.iy == Mesh.YPOS && mP1.iz == Mesh.MIDD ) {
			this.addMeshPart(new MeshPartPlaneX(mFace1 , false, -1, -1, 0)); // 
			this.addMeshPart(new MeshPartPlaneY(mFace2, true, -1, -1, 0 )); // 
			this.addMeshPart(null); //
		}
		else if(mP1.ix == Mesh.XNEG && mP1.iy == Mesh.MIDD && mP1.iz == Mesh.ZPOS ) {
			this.addMeshPart(new MeshPartPlaneX(mFace1 , false, -1, 0, -1)); // 
			this.addMeshPart(null); //
			this.addMeshPart(new MeshPartPlaneZ(mFace3, true, -1 , 0, -1)); // 
		}
		else if(mP1.ix == Mesh.MIDD && mP1.iy == Mesh.YNEG && mP1.iz == Mesh.ZPOS ) {
			this.addMeshPart(null); //
			this.addMeshPart(new MeshPartPlaneY(mFace2, false, 0, 2, -1 )); // green *
			this.addMeshPart(new MeshPartPlaneZ(mFace3, true, 0 , 1, -1)); // red
		}
		this.mShouldLoadArrays = false;
	}
	
	
	
	
}


